#include "Pawn.h"
#include "GameboardView.h"

const float Pawn::SIZE = 2. / 3 * GameboardView::FRAME_SIZE;

Pawn::Pawn(Vec4 color)
{
	ref_ptr<Vec3Array> vertexArray = new Vec3Array;
	vertexArray->push_back(Vec3(0,SIZE,0));
	vertexArray->push_back(Vec3(SIZE,SIZE,0));
	vertexArray->push_back(Vec3(SIZE,0,0));
	vertexArray->push_back(Vec3(0,0,0));
	vertexArray->push_back(Vec3(SIZE/2,SIZE/2,SIZE));
	this->setVertexArray(vertexArray);

	ref_ptr<Vec4Array> colorArray = new Vec4Array;
	colorArray->push_back(color);
	this->setColorArray(colorArray);
	this->setColorBinding(Geometry::BIND_OVERALL);

	ref_ptr<Vec3Array> normalArray = new Vec3Array;
	normalArray->push_back(Vec3(0,0,-1));
	normalArray->push_back(Vec3(1,0,2));
	normalArray->push_back(Vec3(1,0,2));
	normalArray->push_back(Vec3(0,1,2));
	normalArray->push_back(Vec3(-1,0,2));
	this->setNormalArray(normalArray);
	this->setNormalBinding(Geometry::BIND_PER_VERTEX);

	ref_ptr<DrawElementsUInt> drawElements = new DrawElementsUInt(GL_QUADS);
	drawElements->push_back(3);
	drawElements->push_back(2);
	drawElements->push_back(1);
	drawElements->push_back(0);
	this->addPrimitiveSet(drawElements);

	drawElements = new DrawElementsUInt(GL_TRIANGLES);
	drawElements->push_back(4);
	drawElements->push_back(3);
	drawElements->push_back(2);

	drawElements->push_back(4);
	drawElements->push_back(2);
	drawElements->push_back(1);

	drawElements->push_back(4);
	drawElements->push_back(1);
	drawElements->push_back(0);

	drawElements->push_back(4);
	drawElements->push_back(0);
	drawElements->push_back(3);
	this->addPrimitiveSet(drawElements);
}

Pawn::~Pawn(void)
{
}
